﻿<?php
$this->Html->scriptBlock($scriptWindowMsg, array('inline' => false));
$this->Html->scriptBlock($script, array('inline' => false));
?>
<?php
    $this->Html->scriptBlock($scriptSearchBox, array('inline' => false));
?>
<div class="title-body-content"><?php echo $title_for_layout; ?></div>
<div class="searchbox">
    <input type="text" id="search_text" name="sesearch_text" class="searchinput" />
    <input type="checkbox" id="search_paid" name="search_paid" value="1" /> Paid
    <input type="button" id="search_button" value="Search" class="searchbutton" />
</div>
<div class="wrapper-table clearfix">
    <table class="tbl-broking" border="1">
        <tr class="title-tbl" >
            <td class="td-ref-payment"><?php echo $this->Paginator->sort('refid_edit','Reference#'); ?></td>
            <td class="td-paid"><?php echo $this->Paginator->sort('broker_date','Due date'); ?></td>
            <td class="td-payer"><?php echo $this->Paginator->sort('payer', 'Payer'); ?></td>
            <td class="td-paid"><?php echo $this->Paginator->sort('paid', 'Paid'); ?></td>
            <td class="td-sel-all"><?php echo __('<span class="checkall">Check All</span><input type="hidden" id="checkflag" value="0">'); ?></td>
            <td class="td-menu"><?php echo __('Actions'); ?></td>
        </tr>
        <?php
        foreach ($paymentschedules AS $paymentschedule) {
            if(($paymentschedule['Paymentschedule']['broker_amount'] - $paymentschedule['Paymentschedule']['paid_amount']) == 0){ 
                $checked = '&#10003;';
            }else{
                $checked = '';
            }
            $actions = '<li>' . $this->Html->link(__('Edit'), array(
                        'controller' => 'paymentschedules',
                        'action' => 'edit',
                        $paymentschedule['Paymentschedule']['id'],
                    )) . '</li>';
            $actions .= ' ' . $this->Layout->adminRowActions($paymentschedule['Paymentschedule']['id']);

            echo '
                    <tr class="line-content-tbl" >
                        <td class="td-ref-payment" style="text-align:left; padding-left:5px;">' . $paymentschedule['Paymentschedule']['refid_edit'] . '</td>
                        <!--<td class="td-paid" >' . date('m/d/Y', strtotime($paymentschedule['Paymentschedule']['broker_date'])) . '</td>-->
                        <td class="td-paid" >' . date('m/d/Y', strtotime($paymentschedule['Paymentschedule']['broker_date'])) . '</td>
                        <td class="td-payer" style="text-align:left; padding-left:5px;"> ' . $paymentschedule['Paymentschedule']['payer_name'] . '</td>
                        <td class="td-paid">
                            ' . $checked . '
                        </td>
                        <td class="td-sel-all">
                            <input type="checkbox" class="chk-payment-schedule" name="chk_payment[]" value="' . $paymentschedule['Paymentschedule']['id'] . '">
                        </td>
                        <td class="td-action">
                            <ul>
                                ' . $actions . '
                            </ul>
                        </td>
                    </tr>';
        }
        ?>
    </table>
    <div class="wrapper-table clearfix" style="font-style: italic;">
        Reports will show data for checked items except that Installment Tracking shows ALL installments for the selected Account Resume (Ref#).
    </div>
    <div class="wrapper-paging">
        <ul class="ul-paging">
            <?php echo $this->Paginator->numbers(array('tag' => 'li', 'separator' => '')); ?>
        </ul>
        <?php #echo $this->Paginator->counter(array('format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%'))); ?>
    </div>
    
    <div class="wrapper-button-form clearfix">
        <div class="button-form clearfix">
            <div class="button-aihre button-blue"><?php echo $this->Html->link(__('NEW'), array('action' => 'add')); ?></div>
            <div class="button-aihre button-blue"><a href="JavaScript:void(0)" class="payment_schedules"><?php echo __('PAYMENT SCHEDULE REPORT') ?></a></div>
            <div class="button-aihre button-blue"><a href="JavaScript:void(0)" class="payment_tracking"><?php echo __('PAYMENT TRACKING REPORT') ?></a></div>
            <div class="button-aihre button-blue"><a href="JavaScript:void(0)" class="revenue_commission"><?php echo __('COMMISSION REPORT') ?></a></div>
            <div class="button-aihre button-blue"><a href="JavaScript:void(0)" class="installment_tracking"><?php echo __('INSTALLMENT TRACKING REPORT') ?></a></div>
        </div>
    </div>
    <div class="wrapper-button-form clearfix">
        <div class="button-form clearfix">
            <div class="button-aihre button-blue"><a href="JavaScript:void(0)" class="open_trade_account_report"><?php echo __('OPEN TRADE ACCOUNT REPORT') ?></a></div>
        </div>
    </div>
</div>